#include <stdio.h>
#include "esp_system.h"
#include "esp_heap_caps.h"

void printInfo(void)
{
    // 1. 打印整个堆剩余内存
//     printf("Free heap size: %ld bytes\n", esp_get_free_heap_size());

    // 2. 打印不同类型内存的剩余大小和最大可分配块
    printf("Free internal heap (default): %d bytes, Largest block: %d bytes\n",
           heap_caps_get_free_size(MALLOC_CAP_DEFAULT),
           heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT));

//     printf("Free 8-bit capable heap: %d bytes, Largest block: %d bytes\n",
//            heap_caps_get_free_size(MALLOC_CAP_8BIT),
//            heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));

//     printf("Free 32-bit capable heap: %d bytes, Largest block: %d bytes\n",
//            heap_caps_get_free_size(MALLOC_CAP_32BIT),
//            heap_caps_get_largest_free_block(MALLOC_CAP_32BIT));

//     printf("Free DMA-capable heap: %d bytes, Largest block: %d bytes\n",
//            heap_caps_get_free_size(MALLOC_CAP_DMA),
//            heap_caps_get_largest_free_block(MALLOC_CAP_DMA));

#if CONFIG_SPIRAM
    // 如果启用了 PSRAM，这里也能看到
    printf("Free external PSRAM heap: %d bytes, Largest block: %d bytes\n",
           heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
           heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM));
#endif
}